package frmwrk.db.internal.classes;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

import utils.Tracer;

import frmwrk.db.publicInterface.ISession;


public class CSession implements ISession{
	private Statement statement;
	
	public CSession(Statement pStatement){
		statement = pStatement;
	}
	
	@Override
 	public ResultSet query(String pSql){
		try {
			return statement.executeQuery(pSql);
		} catch (SQLException e) {
			Tracer.trace(e);
			return null;
		}
	}

	public ResultSet insert(String sql, CQueryParam[] params){
		try {
			int len = params.length;


			for(int i = 0; i < len; i++)
				sql.replace(params[i].name, params[i].getValue());     

			statement.executeUpdate(sql);

			return null;
		} catch (SQLException e) {
			Tracer.trace(e);
			return null;
		}
	}

}
